﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SchedulerSupreme
{
    class Program
    {
        public static Schedule Demand;
        public static int Cap;
        [STAThread]
        static void Main(string[] args)
        {

            //These regions are disabled when the application UI is active. They remain for purposes of understanding the code
            //and testing.
            
            #region Setup and parse

            //Parser ExcelReader = new Parser();
            //string filepath =Path.GetFullPath(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)+"..\\..\\..\\assets\\inputQ1_2013.xlsx") ;
            //Console.WriteLine(filepath);
            //Demand = ExcelReader.parseIntoSchedule(filepath);
            //Schedule input = new Schedule(5, Demand.Types, Demand.Days, Demand.Slots);
            //Demand.Clone(input);
            //Cap = 10;
            //Console.WriteLine("Total staff hours demanded: {0}", input.Hours);

            ////Assign distribution
            //double[] DepSize = new double[input.Departments];
            //DepSize[0] = 10;
            //DepSize[1] = 10;
            //DepSize[2] = 10;
            //DepSize[3] = 10;
            //DepSize[4] = 10;
            //input.addWeightIndex(DepSize);

            #endregion

            #region local search

            //int rounds = 30000;

            //Console.WriteLine("Cost of input (all in one department): {0}", input.Cost());
            //Schedule Result = input;
            //Searcher engine = new Searcher();
            //int maksProb = 0;

            //Console.WriteLine("Now running {0} iterations of Simulated annealing with liniear drop down from {1}", rounds,maksProb);
            
            //for (int i = 0; i < rounds; i++)
            //{
            //    int prob = (int)(maksProb - (i * 1.0 / rounds) * maksProb);
            //    Result = engine.Metropolis_konstant(Result, prob);
            //    if (i % 100 == 0)
            //    {
            //        Console.WriteLine("The cost after {0} iterations is {1}.", i, Result.Cost());
            //        Console.WriteLine("Costfunction: Demand = {0}, Week = {1}, Quarter = {2} and Cap = {3}", Result.Demanddeviation, Result.Weekdeviation, Result.Yeardeviation,Result.Capcost);
            //    }
            //}

            //Console.WriteLine("Cost of result is {0}", Result.Cost());
            //ExcelReader.printToFile("", Result);
            //Console.ReadKey();
            #endregion

            #region load balance 
            //LoadBalancer LB = new LoadBalancer(input);
            ////Alle fradage er lange efter klokken 14:00
            //LB.distribute_long(new int[1] { 4 }, new int[6] { 0, 1, 2, 3,4, 5}, 12);
            //LB.distribute();
            //List<Shift> vagter = LB.shifts;
            //Schedule result = ExcelReader.shiftsToSchedule(LB.shifts, input.Departments, input.Types, input.Days, input.Slots);

            //Console.WriteLine("Hours added to support min. of 1½ hours shifts: {0}", result.Demanddeviation/2);
            //Console.WriteLine("Deviation in  result: {0}", result.Yeardeviation);
            //Console.WriteLine("Press any key to write result to Excel.");
            //Console.ReadKey();
            //Console.WriteLine("Now writing solution. ETA 1 minute");

            //ExcelReader.printToFile("C:\resultat.xlsx", result);
            #endregion

            #region UI
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new HK_MKC_UI());
            #endregion
        }
    }
}
